﻿using DataLayer.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataLayer.Repositories
{
    public class MessageRepository : Repository<Message>
    {
        public MessageRepository(GameUPContext context) : base(context) { }

        public IEnumerable<Message> GetMessagesReceivedByPlayerId(int idPlayer)
        {
            return _Collection.Where(m => m.IdReceiver.Id == idPlayer);
        }

        public IEnumerable<Message> GetMessagesSendedByPlayerId(int idPlayer)
        {
            return _Collection.Where(m => m.IdSender.Id == idPlayer);
        }

        public void MarkAsRead(int idMessage)
        {
            GetById(idMessage).IsRead = true;
        }

    }
}
